package edu.yzu.testspringboot002.config;

import org.springframework.context.annotation.Configuration;

@Configuration
public class RedisConfig {

    // @Bean
    // public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
    //     RedisTemplate<String, Object> template = new RedisTemplate<>();
    //     template.setConnectionFactory(redisConnectionFactory);
    //     // 使用Jackson2JsonRedisSerializer来序列化和反序列化redis的value值
    //     Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
    //     ObjectMapper objectMapper = new ObjectMapper();
    //     objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
    //     objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
    //     jackson2JsonRedisSerializer.setObjectMapper(objectMapper);
    //     // 使用StringRedisSerializer来序列化和反序列化redis的key值
    //     template.setKeySerializer(new StringRedisSerializer());
    //     template.setValueSerializer(jackson2JsonRedisSerializer);
    //     template.afterPropertiesSet();
    //     return template;


}
